package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0240.java
 * @Author : WangRuoyu
 * @Date 2023/11/18 22:11
 */


public class Q0240 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int x = 0, y = matrix[0].length - 1;
        while (x < matrix.length && y >= 0) {
            if (matrix[x][y] == target) return true;
            if (matrix[x][y] > target) y--;
            else x++;
        }
        return false;
    }

    public static void main(String[] args) {
        Q0240 sl = new Q0240();
    }
}